<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<DecisionMaking.BusinessLogic.Model.CueAttributeModel>" %>
<%@ Import Namespace="DecisionMaking.Domain" %>
<%@ Import Namespace="DecisionMaking.WebApp" %>
<%@ Import Namespace="MvcContrib.UI.Grid" %>
<%@ Import Namespace="MvcContrib.UI.MenuBuilder" %>

<asp:Content ContentPlaceHolderID="TitleContent" runat="server">Describe Cue Attributes</asp:Content>

<asp:Content ContentPlaceHolderID="MenuContent" runat="server">
    <% Html.Menu(Navigation.MainMenu(Url, Model.EnvironmentId)); %>
</asp:Content>

<asp:Content ContentPlaceHolderID="MainContent" runat="server">
	<script type="text/javascript">
        function update(context) {
            // Load and deserialize the returned JSON data
            var json = context.get_data();
            var data = Sys.Serialization.JavaScriptSerializer.deserialize(json);
 
            // delete the row from the grid
			$('#attr-' + data.deletedId).fadeOut();
        }		
	</script>

	<% Html.Grid<CueAttribute>("cueAttributes").Columns( column => {
		column.For(c => c.Name);
		column.For(c => Ajax.ActionLink("Remove", "Delete", new {id = c.Id}, new AjaxOptions{OnSuccess = "update"})).Named("Actions").DoNotEncode();
	})
	.RowAttributes(row => new Dictionary<string, object>{{"id", "attr-" + row.Item.Id}})
	.Render();%>
	
    <%= Html.ValidationSummary("Attribute creation was unsuccessful. Please correct the errors and try again.") %>

    <% using (Html.BeginForm("Add", "CueAttributes")) { %>
        <fieldset>
            <legend>Add Cue Attribute</legend>
        	<%= Html.HiddenFor(m => m.EnvironmentId) %>
            <p class="field-multi-line field-textbox">
                <%= Html.LabelFor(m => m.Name) %>
                <%= Html.TextBoxFor(m => m.Name) %>
                <%= Html.ValidationMessageFor(m => m.Name) %>
            </p>
            <p>
                <input type="submit" value="Add" />
            </p>            
        </fieldset>
    <% } %>    	
	<p>
		<%= Html.ActionLink("Next", "List", "Cues", new { Id = Model.EnvironmentId }, null)%>
	</p>
</asp:Content>

